/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Plantillas.java
 *
 * Created on 30-may-2009, 18:51:15
 */

package GUI;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import jess.*;

/**
 *
 * @author Tony
 */
public class Plantillas extends javax.swing.JFrame {

    private JFrame framePrincipal;
    private Vector vector;
    BufferedWriter writer;
    BufferedReader reader;
    Rete engine;
    Batch batch;
    /** Creates new form Consejos */
    public Plantillas (JFrame fr) throws JessException {
    	engine = new Rete ();
    	batch = new Batch();
        this.setVisible(true);
        this.framePrincipal=fr;
        initComponents();

    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jComboBox6 = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jComboBox7 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jComboBox8 = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Plantilla de curriculum que se ajusta a su perfil");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "18-23", "24-29", "30-40", "+40" }));

        jLabel2.setText("Edad");

        jLabel3.setText("Formación");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "analfabeto", "primaria", "ESO", "bachiller", "Estudiando Carrera", "Titulo Universitario" }));

        jLabel4.setText("Otros titulos");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguno", "Master", "Doctorado" }));

        jLabel5.setText("Idiomas");

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguno", "uno", "dos" }));

        jLabel6.setText("Conocimientos");

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manejo Internet", "Ofimatica", "Programas Especializados", "Conocimiento avanzado de SSOO" }));

        jLabel7.setText("Permiso Cond.");

        jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Si", "No" }));

        jLabel8.setText("Disponibilidad");

        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jornada Completa", "Media Jornada", "Fin de Semana Completa", "Fin de Semana Media", "Total" }));

        jButton1.setText("Volver");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Asesorar");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        jLabel9.setText("Experiencia");

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Si", "No" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(59, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31))
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(46, 46, 46)
                        .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox4, 0, 82, Short.MAX_VALUE)
                            .addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox5, 0, 141, Short.MAX_VALUE)
                            .addComponent(jComboBox7, 0, 141, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addComponent(jButton2)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9)
                            .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(50, 50, 50))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
    int edad = jComboBox1.getSelectedIndex();
    int form = jComboBox2.getSelectedIndex();
    int otros = jComboBox3.getSelectedIndex();
    int idi = jComboBox4.getSelectedIndex();
    int cono = jComboBox5.getSelectedIndex();
    int permiso = jComboBox6.getSelectedIndex();
    int disp = jComboBox7.getSelectedIndex();
    int exp = jComboBox8.getSelectedIndex();
    System.out.println(edad);
    System.out.println(form);
    System.out.println(otros);
    System.out.println(idi);
    System.out.println(cono);
    System.out.println(permiso);
    System.out.println(disp);
    System.out.println(exp);
    try {
    if (edad==0)
            engine.assertString("(edad 1)");
    else if(edad==1)
            engine.assertString("(edad 2)");
    else if(edad==2)
            engine.assertString("(edad 3)");
    else
            engine.assertString("(edad 4)");
    if (form==0)
            engine.assertString("(fAcademica 0)");
    else if(form==1)
            engine.assertString("(fAcademica 1)");
    else if(form==2)
            engine.assertString("(fAcademica 2");
    else if(form==3)
            engine.assertString("(fAcademica 3)");
    else if(form==4)
            engine.assertString("(fAcademica 4)");
    else
            engine.assertString("(fAcademica 5)");
    if (otros==0)
            engine.assertString("(titulos 0)");
    else if(otros==1)
            engine.assertString("(titulos 1)");
    else
            engine.assertString("(titulos 2");
    if (idi==0)
            engine.assertString("(idiomas 0)");
    else if(idi==1)
            engine.assertString("(idiomas 1)");
    else
            engine.assertString("(idiomas 2");
    if (cono==0)
            engine.assertString("(informatica 4)");
    else if(cono==1)
            engine.assertString("(informatica 3)");
    else if(cono==2)
            engine.assertString("(informatica 2)");
    else
            engine.assertString("(informatica 1)");
    if (permiso==0)
            engine.assertString("(carnet 1)");
    else
            engine.assertString("(carnet 0)");
    if (disp==0)
            engine.assertString("(disponibilidad 4)");
    else if(disp==1)
            engine.assertString("(disponibilidad 3)");
    else if(disp==2)
            engine.assertString("(disponibilidad 2)");
    else if(disp==3)
            engine.assertString("(disponibilidad 1)");
    else
            engine.assertString("(disponibilidad 5)");
    if (exp==0)
            engine.assertString("(experiencia 1)");
    else
            engine.assertString("(experiencia 0)");

    engine.assertString("(empezar ok)");
    
    //engine.batch("GUI/plantilla.clp");
    batch.batch("./GUI/plantilla.clp",engine);
                String linea;
               BufferedReader reader2;
            try {
                reader2 = new BufferedReader(new InputStreamReader(new FileInputStream("C://salida.txt")));
                try {
                    linea = reader2.readLine();
                    JFrame  u= new Salida_Consejos(this.framePrincipal,linea);
                } catch (IOException ex) {
                    Logger.getLogger(Plantillas.class.getName()).log(Level.SEVERE, null, ex);
                }
                this.setVisible(false);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Plantillas.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (JessException ex) {
            Logger.getLogger(Plantillas.class.getName()).log(Level.SEVERE, null, ex);
        }





    }//GEN-LAST:event_jButton2MouseClicked

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    this.setVisible(false);
    this.framePrincipal.setVisible(true);        
    }//GEN-LAST:event_jButton1MouseClicked

    /**
    * @param args the command line arguments
    */


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    // End of variables declaration//GEN-END:variables

}
